<?php

class add_addr{
public function index()
{
$email = strim($GLOBALS['request']['email']);
$pwd = strim($GLOBALS['request']['pwd']);
$user = user_check($email,$pwd);
$user_id  = intval($user['id']);
$root = array();
$root['return'] = 1;
if($user_id>0)
{
$root['user_login_status'] = 1;
$id = intval($GLOBALS['request']['id']);
$addr = array();
$addr['user_id'] = $user_id;
$addr['region_lv1'] = intval($GLOBALS['request']['region_lv1']);
$addr['region_lv2'] = intval($GLOBALS['request']['region_lv2']);
$addr['region_lv3'] = intval($GLOBALS['request']['region_lv3']);
$addr['region_lv4'] = intval($GLOBALS['request']['region_lv4']);
$addr['consignee'] = addslashes(trim($GLOBALS['request']['consignee']));
$addr['address'] = addslashes(trim($GLOBALS['request']['delivery_detail']));
$addr['mobile'] = addslashes(trim($GLOBALS['request']['phone']));
$addr['zip'] = addslashes(trim($GLOBALS['request']['postcode']));
if ($id == 0){
$GLOBALS['db']->autoExecute(DB_PREFIX.'user_consignee',$addr,'INSERT');
$addr_id = $GLOBALS['db']->insert_id();
}else{
$GLOBALS['db']->autoExecute(DB_PREFIX.'user_consignee',$addr,'UPDATE',"user_id = {$user_id} and id = {$id}");
$addr_id = $id;
}
$root['id'] = $addr_id;
}
else
{
$root['user_login_status'] = 0;
}
output($root);
}
}

?>